<?php 
require ( 'DataManage.php' );
?>
<html>
<head>
<title>欢迎使用K_Crawler信息检索工具</title>
</head>

<body>
欢迎使用K_Crawler信息检索工具
<form action="#" method="get">
<input type="text" name="ss" <?php if(isset($_GET['ss'])) echo "value=\"".$_GET['ss']."\"" ?> />
<input type="submit" name="s" value="搜索" />
</form>
<?php
if(isset($_GET['ss']))
{
	$var = explode(' ', $_GET['ss']);
	$strsql = "select a.domain,b.path,c.params,c.title from k_url_root as a,k_url_path as b,k_page as c where a.id_domain=c.id_domain and b.id_path=c.id_path and ( c.title=\"-\"";
	foreach($var as $v)
	{
		$strsql = $strsql."or c.title like \"%".$v."%\" ";	
	}
	$strsql = $strsql.")";
//echo $strsql;
	$result = DataManage::GetInstance()->query($strsql)->fetchAll();
	if(0 == count($result))
	{
		echo "<br/>搜索结果为空！<br/>";
	}
	else
	{
		echo "<table border=\"1\"><tr><td>标题</td><td>地址</td></tr>";
		foreach( $result as $col)
		{
			echo "<tr><td>".$col['title']."</td>";
			$url = $col['domain'];
			if("/" != $col['path'])
			{
				$url = $url.$col['path'];
				if("?" != $col['params'])
				{
					$url = $url.$col['params'];
				}
			}
			echo "<td><a href=\"http://".$url."\">".$url."</a></td>";
			echo "</td></tr>";
		}	
		echo "</table>";
	}
}
?>



</body>
</html>
